package top.zkh.login;

import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import com.java1234.util.DbUtil;
import com.java1234.dao.animalDao;
import com.java1234.model.animal;
public class deleteServlet extends HttpServlet{
	private DbUtil dbUtil=new DbUtil();
	private animalDao animaldao=new animalDao();
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding ("utf-8");
		resp.setContentType("text/html;carset=utf-8");
		String key = req.getParameter("ID");
		Connection con=null;
		try {
			con=dbUtil.getCon();
			int deleteNum = animaldao.delete(con, key);
			if(deleteNum==1) {
				req.getRequestDispatcher("delete.jsp").forward(req, resp);
			}else {
				req.getRequestDispatcher("error.jsp").forward(req, resp);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		};

	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		this.doGet(req, resp);
	}
}
